package com.srxz.mobilepharmacy.controller;

import com.srxz.mobilepharmacy.service.LoginService;
import com.srxz.mobilepharmacy.util.back.BackMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.math.BigInteger;

/**
 * 登陆/退出
 */
@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;

    @GetMapping("/login")
    public BackMessage login(BigInteger aid, String uname, String password, Integer house, HttpSession session){
        if(aid == null || StringUtils.isEmpty(uname) || StringUtils.isEmpty(password) || house == null){
            return BackMessage.error("登陆信息不完整");
        }
        return loginService.login(aid, uname, password, house, session);
    }

    @GetMapping("/timeout")
    public BackMessage sessionout(){
        return BackMessage.sessionTimeOut();
    }




}
